﻿using System;
using System.Windows.Forms;
using Magellan.ProjectWizards.Manager.Commands;

namespace Magellan.ProjectWizards.Manager
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var command = null as ICommand;
            var text = null as string;
            if (args.Length > 0 && args[0] == "-u")
            {
                text = "Uninstalling Project Templates...";
                command = new UninstallTemplateCommand();
            }
            else
            {
                text = "Installing Project Templates...";
                command = new InstallTemplateCommand();
            }

            var completeSuccess = false;
            ProgressDialog.Show(
                text,
                () => completeSuccess = command.Execute());

            return completeSuccess ? 0 : 1;
        }
    }
}
